package edu.biwu;

import jakarta.servlet.*;

import java.io.IOException;


/**
 * 新建一个Java类，需要实现jakarta。servlet。Servlet接口
 * 只有实现这个Servlet接口，才能说明它是一个服务端小程序，讲啦可以处理用户的请求
 */
public class ServletDemo01 implements Servlet {
    @Override
    public void init(ServletConfig config) throws ServletException {

    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    /**
     * 处理客户端发送过来的请求
     * @param req the <code>ServletRequest</code> object that contains the client's request
     *
     * @param res the <code>ServletResponse</code> object that contains the servlet's response
     *
     * @throws ServletException
     * @throws IOException
     */
    @Override
    public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
        System.out.println("Hello Servlet");
        res.getWriter().write("<font color='red'>Hello Servlet</font>");
    }

    @Override
    public String getServletInfo() {
        return "";
    }

    @Override
    public void destroy() {

    }
}
